﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using System.Threading;
using EasyAbp.Abp.Trees;

namespace Joy.Erp.BasicArchives.Core
{
    public interface ITreeArchiveRepository<TEntity> : ITreeRepository<TEntity> where TEntity : class, IArchiveAggregateRoot, ITree<TEntity>
    {
        /// <summary>
        /// 批量插入实体（高性能）
        /// </summary>
        Task BulkInsertAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default);

        /// <summary>
        /// 批量更新实体（高性能）
        /// </summary>
        Task BulkUpdateAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default);

        /// <summary>
        /// 批量删除实体（高性能）
        /// </summary>
        Task BulkDeleteAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default);

        Task<List<TEntity>> GetPagedListAsync(
            string filter,
            int skipCount = int.MaxValue,
            int maxResultCount = 0,
            string sorting = null,
            bool includeDetails = false,
            CancellationToken cancellationToken = default);

        Task<List<TEntity>> GetPagedListAsync(
            Expression<Func<TEntity, bool>> predicate,
            int skipCount = int.MaxValue,
            int maxResultCount = 0,
            string sorting = null,
            bool includeDetails = false,
            CancellationToken cancellationToken = default);

        Task<long> GetCountAsync(bool includeDetails = false, CancellationToken cancellationToken = default);

        Task<long> GetCountAsync(Expression<Func<TEntity, bool>> predicate, bool includeDetails = false, CancellationToken cancellationToken = default);
    }
}
